首先载入工具包和数据

载入工具包…

library(dppbar)

载入数据…

为了完整的展示工具包的用途,我们使用了两种不同结构的数据集。它们分别是 中国房地产企业财报数据(2007-2016)和中国的一些宏观经济数据(2008-2016),数据详情见下方。

中国房地产企业财报数据(2007-2016)

##   Year 证券代码. 证券简称 season  roa
## 1 2007 000002.SZ    万科A      2 8.18
## 2 2008 000002.SZ    万科A      2 6.66
## 3 2009 000002.SZ    万科A      2 7.37
## 4 2010 000002.SZ    万科A      2 8.86
## 5 2011 000002.SZ    万科A      2 8.09

中国的一些宏观经济数据(2008-2016)

##   year     ROE   CPI   PPI      GDP
## 1 2008 -0.4826 105.9 106.9 319515.5
## 2 2009  0.2078  99.3  94.6 349081.4
## 3 2010  0.2028 103.3 105.5 413030.3
## 4 2011  0.3533 105.4 106.0 489300.6
## 5 2012  0.2597 102.6  98.3 540367.4

用5行以内的代码完成绘图:

bar_plot(dataframe=estate_fin_charts,ctg.idx = 'Year',num.idx = 'income',
         condition.idx = '证券简称',criteria=2016,top_N=10,
         colors=brewer.pal(12,'Set3'),xaxis_name='年份',yaxis_name='营业收入(亿元)',
         title='2016年营业收入前12名房地产企业历年营收变化',
         paper_bgcolor='#ccece6',margin=list(t=36,l=24))
bar_plot(dataframe=macro_data_chn,ctg.idx='year',num.idx=c(9:12),
         criteria = 2016,colors = brewer.pal(4,'Set1'),
         xaxis_name = '年份',yaxis_name = '商品价格(元/吨)',
         title='一些大宗商品的历年价格变化',
         paper_bgcolor='#ccece6',margin=list(t=36,l=24))

回到: Blogs